<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的预约 - 人才职业生涯规划平台</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <!-- 稍后添加 appointments.css -->
    <style>
        /* 临时基本样式 */
        body {
            background-color: #f8f9fa;
        }
        .app-container {
            max-width: 450px;
            margin: 0 auto;
        }
        .appointments-page {
             padding-bottom: calc(50px + env(safe-area-inset-bottom, 0));
        }
        .page-header {
            display: flex;
            align-items: center;
            padding: 15px;
            background-color: #fff;
            position: sticky;
            top: 0;
            z-index: 100;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        }
        .back-button {
            border: none;
            background: none;
            font-size: 20px;
            color: #333;
            padding: 0 10px 0 0;
            display: flex;
            align-items: center;
            cursor: pointer;
        }
        .page-title {
            font-size: 18px;
            font-weight: 600;
            flex: 1;
            text-align: center;
            margin-right: 30px; /* 补偿返回按钮宽度 */
        }
        .main-content {
            padding: 10px 15px;
        }
        /* 底部导航样式 - 保持一致 */
        .tab-bar { height: 50px; position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 450px; z-index: 1000; display: flex; justify-content: space-around; align-items: center; background-color: #fff; border-top: 1px solid #eee; box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.05); opacity: 1; transition: all 0.3s ease; padding-bottom: env(safe-area-inset-bottom, 0); }
        .tab-bar-hidden { transform: translateX(-50%) translateY(100%); opacity: 0; pointer-events: none; }
        .tab-bar .tab-item { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; height: 100%; color: #8e8e93; font-size: 10px; position: relative; text-decoration: none; padding: 0; }
        .tab-bar .tab-item.active { color: #4a6fee; font-weight: normal; }
        .tab-bar .tab-item i { font-size: 20px; margin-bottom: 2px; transition: all 0.3s ease; }
        .tab-bar .tab-item span { font-size: 10px; line-height: 1; transition: all 0.3s ease; }
        .tab-bar .tab-item.active::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 16px; height: 2px; border-radius: 1px; background-color: #4a6fee; }
        
        /* 状态筛选选项卡 */
        .status-tabs {
            display: flex;
            background-color: #fff;
            padding: 0 10px;
            border-bottom: 1px solid #eee;
            margin: 0 -15px 10px; /* 左右贴边 */
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            white-space: nowrap;
            position: sticky;
            top: 55px; /* 假设头部高度55px */
            z-index: 99;
        }
        
        .status-tabs .tab {
            padding: 12px 15px;
            font-size: 15px;
            color: #666;
            position: relative;
            cursor: pointer;
            transition: color 0.3s;
            border-bottom: 3px solid transparent;
        }
        
        .status-tabs .tab.active {
            color: #4a6fee;
            font-weight: 500;
            border-bottom-color: #4a6fee;
        }
        
        /* 预约卡片 */
        .appointment-card {
            background-color: #fff;
            border-radius: 10px;
            padding: 15px;
            margin-bottom: 15px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        }
        
        .agent-info {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .agent-avatar {
            width: 45px;
            height: 45px;
            border-radius: 50%;
            object-fit: cover;
            margin-right: 12px;
        }
        
        .agent-details {
            display: flex;
            flex-direction: column;
        }
        
        .agent-name {
            font-size: 16px;
            font-weight: 500;
            color: #333;
            margin-bottom: 3px;
        }
        
        .agent-title {
            font-size: 13px;
            color: #666;
        }
        
        .appointment-details {
            margin-bottom: 15px;
            padding-top: 10px;
            border-top: 1px solid #f5f5f5;
        }
        
        .appointment-details p {
            font-size: 14px;
            color: #555;
            margin: 8px 0;
            display: flex;
            align-items: center;
        }
        
        .appointment-details p i {
            margin-right: 8px;
            color: #888;
            font-size: 16px;
            width: 16px; /* 固定图标宽度 */
            text-align: center;
        }
        
        .status-tag {
            display: inline-block;
            padding: 3px 8px;
            font-size: 12px;
            border-radius: 4px;
            font-weight: 500;
        }
        
        .status-pending {
            background-color: #fff3e0; /* 浅橙 */
            color: #ffa726; /* 橙色 */
        }
        
        .status-ongoing {
            background-color: #e3f2fd; /* 浅蓝 */
            color: #42a5f5; /* 蓝色 */
        }
        
        .status-completed {
            background-color: #e8f5e9; /* 浅绿 */
            color: #66bb6a; /* 绿色 */
        }
        
        .status-cancelled {
            background-color: #fce4ec; /* 浅粉 */
            color: #f48fb1; /* 粉色 */
        }
        
        .appointment-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            padding-top: 10px;
            border-top: 1px solid #f5f5f5;
        }
        
        /* 按钮小尺寸 */
        .btn-sm {
            padding: 4px 10px;
            font-size: 13px;
        }
        .btn { padding: 6px 15px; border-radius: 6px; font-size: 14px; cursor: pointer; border: 1px solid transparent; transition: all 0.3s ease; }
        .btn-primary { background-color: #4a6fee; color: white; border-color: #4a6fee; }
        .btn-primary:hover { opacity: 0.9; }
        .btn-secondary { background-color: #f1f3f5; color: #6c757d; border-color: #dee2e6; }
        .btn-secondary:hover { background-color: #e9ecef; }

        /* 空状态 */
        .empty-state { text-align: center; padding: 40px 20px; color: #666; }
        .empty-state img { width: 80px; height: 80px; margin-bottom: 15px; opacity: 0.7; }
        .empty-state p { font-size: 15px; margin-bottom: 15px; }
    </style>
</head>
<body>
    <div class="app-container appointments-page">
        <!-- 头部导航 -->
        <header class="page-header">
            <button class="back-button" onclick="history.back()">
                <i class="bi bi-chevron-left"></i>
            </button>
            <h1 class="page-title">我的预约</h1>
        </header>

        <!-- 主内容区域 -->
        <main class="main-content">
            <!-- 状态筛选选项卡 (可选) -->
            <div class="status-tabs">
                <div class="tab active" data-status="all">全部</div>
                <div class="tab" data-status="pending">预约中</div>
                <div class="tab" data-status="ongoing">陪跑中</div>
                <div class="tab" data-status="completed">已完成</div>
                <div class="tab" data-status="cancelled">已取消</div>
            </div>
            
            <!-- 预约列表容器 -->
            <div class="appointments-list">
                <!-- 示例：预约中 -->
                <div class="appointment-card" data-status="pending">
                    <div class="agent-info">
                        <img src="../img/agent1.jpg" alt="经纪人头像" class="agent-avatar">
                        <div class="agent-details">
                            <span class="agent-name">王老师</span>
                            <span class="agent-title">资深职业规划师</span>
                        </div>
                    </div>
                    <div class="appointment-details">
                        <p><i class="bi bi-calendar-check"></i> 预约时间：2023-05-10 14:00</p>
                        <p><i class="bi bi-clock"></i> 服务时长：60分钟</p>
                        <p><i class="bi bi-info-circle"></i> 状态：<span class="status-tag status-pending">预约中</span></p>
                    </div>
                    <div class="appointment-actions">
                        <button class="btn btn-secondary btn-sm" onclick="cancelAppointment(this)">取消预约</button>
                        <a href="appointment-detail.html?status=pending&id=AP202305100001" class="btn btn-primary btn-sm">查看详情</a>
                    </div>
                </div>
                
                <!-- 示例：陪跑中 -->
                <div class="appointment-card" data-status="ongoing">
                    <div class="agent-info">
                        <img src="../img/agent2.jpg" alt="经纪人头像" class="agent-avatar">
                        <div class="agent-details">
                            <span class="agent-name">李顾问</span>
                            <span class="agent-title">互联网行业专家</span>
                        </div>
                    </div>
                    <div class="appointment-details">
                        <p><i class="bi bi-calendar-check"></i> 开始时间：2023-05-08 10:00</p>
                        <p><i class="bi bi-clock"></i> 剩余时长：约 45 分钟</p>
                        <p><i class="bi bi-info-circle"></i> 状态：<span class="status-tag status-ongoing">陪跑中</span></p>
                    </div>
                    <div class="appointment-actions">
                        <a href="appointment-detail.html?status=ongoing&id=AP202305080001" class="btn btn-primary btn-sm">进入陪跑室</a>
                    </div>
                </div>
                
                 <!-- 示例：已完成 -->
                <div class="appointment-card" data-status="completed">
                    <div class="agent-info">
                        <img src="../img/agent3.jpg" alt="经纪人头像" class="agent-avatar">
                        <div class="agent-details">
                            <span class="agent-name">赵老师</span>
                            <span class="agent-title">HR 招聘专家</span>
                        </div>
                    </div>
                    <div class="appointment-details">
                        <p><i class="bi bi-calendar-check"></i> 完成时间：2023-05-01 16:30</p>
                        <p><i class="bi bi-clock"></i> 服务时长：60分钟</p>
                        <p><i class="bi bi-info-circle"></i> 状态：<span class="status-tag status-completed">已完成</span></p>
                    </div>
                    <div class="appointment-actions">
                        <a href="appointment-detail.html?status=completed&id=AP202305010001" class="btn btn-secondary btn-sm">评价服务</a>
                        <a href="appointment-detail.html?status=completed&id=AP202305010001" class="btn btn-secondary btn-sm">查看详情</a>
                    </div>
                </div>
                
                 <!-- 示例：已取消 -->
                <div class="appointment-card" data-status="cancelled">
                    <div class="agent-info">
                        <img src="../img/agent1.jpg" alt="经纪人头像" class="agent-avatar">
                        <div class="agent-details">
                            <span class="agent-name">王老师</span>
                            <span class="agent-title">资深职业规划师</span>
                        </div>
                    </div>
                    <div class="appointment-details">
                        <p><i class="bi bi-calendar-x"></i> 取消时间：2023-05-09 11:00</p>
                        <p><i class="bi bi-clock"></i> 原预约时间：2023-05-10 14:00</p>
                        <p><i class="bi bi-info-circle"></i> 状态：<span class="status-tag status-cancelled">已取消</span></p>
                    </div>
                    <div class="appointment-actions">
                        <button class="btn btn-secondary btn-sm">重新预约</button>
                        <a href="appointment-detail.html?status=cancelled&id=AP202305090001" class="btn btn-secondary btn-sm">查看详情</a>
                    </div>
                </div>
            </div>
            
             <!-- 空状态 -->
            <div class="empty-state" style="display: none;">
                <img src="../img/empty-appointments.svg" alt="暂无预约">
                <p>您还没有相关的预约记录</p>
                <a href="agents.html" class="btn btn-primary">寻找经纪人</a>
            </div>
        </main>

        <!-- 底部导航栏 -->
        <footer class="tab-bar">
            <a href="../index.html" class="tab-item">
                <i class="bi bi-house-door"></i>
                <span>首页</span>
            </a>
            <a href="discover.html" class="tab-item">
                <i class="bi bi-compass"></i>
                <span>发现</span>
            </a>
            <a href="agents.html" class="tab-item">
                <i class="bi bi-person-rolodex"></i>
                <span>经纪人</span>
            </a>
            <a href="profile.html" class="tab-item active">
                <i class="bi bi-person-fill"></i>
                <span>我的</span>
            </a>
        </footer>
    </div>

    <script src="../js/nav.js"></script>
    <script>
        // 底部导航栏滚动隐藏逻辑 (与 profile 页相同)
        document.addEventListener('DOMContentLoaded', function() {
            let lastScrollTop = 0;
            let scrollTimer;
            const tabBar = document.querySelector('.tab-bar');
            const scrollThreshold = 20;
            function handleScroll() {
                const currentScrollTop = window.pageYOffset || document.documentElement.scrollTop;
                if (Math.abs(lastScrollTop - currentScrollTop) > scrollThreshold) {
                    if (currentScrollTop > lastScrollTop && currentScrollTop > 100) {
                        if (tabBar) tabBar.classList.add('tab-bar-hidden');
                    } else if (currentScrollTop < lastScrollTop) {
                        if (tabBar) tabBar.classList.remove('tab-bar-hidden');
                    }
                    lastScrollTop = currentScrollTop;
                }
                clearTimeout(scrollTimer);
                scrollTimer = setTimeout(function() {
                    if (tabBar) tabBar.classList.remove('tab-bar-hidden');
                }, 1000);
            }
            window.addEventListener('scroll', handleScroll);
            
            // 状态选项卡筛选功能
            const statusTabs = document.querySelectorAll('.status-tabs .tab');
            const appointmentCards = document.querySelectorAll('.appointment-card');
            const appointmentsList = document.querySelector('.appointments-list');
            const emptyState = document.querySelector('.empty-state');

            function filterAppointments(selectedStatus) {
                let hasVisibleCards = false;
                appointmentCards.forEach(card => {
                    const cardStatus = card.getAttribute('data-status');
                    if (selectedStatus === 'all' || cardStatus === selectedStatus) {
                        card.style.display = 'block';
                        hasVisibleCards = true;
                    } else {
                        card.style.display = 'none';
                    }
                });
                // 显示或隐藏空状态
                if (emptyState) {
                    emptyState.style.display = hasVisibleCards ? 'none' : 'block';
                }
            }

            statusTabs.forEach(tab => {
                tab.addEventListener('click', function() {
                    // 更新选项卡激活状态
                    statusTabs.forEach(t => t.classList.remove('active'));
                    this.classList.add('active');
                    
                    // 获取选择的状态并筛选
                    const selectedStatus = this.getAttribute('data-status');
                    filterAppointments(selectedStatus);
                });
            });

            // 初始加载时显示全部
            filterAppointments('all'); 
            
            // --- 示例：按钮交互 (需要根据实际业务逻辑扩展) ---
            const actionButtons = document.querySelectorAll('.appointment-actions button');
            actionButtons.forEach(button => {
                button.addEventListener('click', function() {
                    const action = this.textContent;
                    const card = this.closest('.appointment-card');
                    const agentName = card.querySelector('.agent-name').textContent;
                    console.log(`点击了卡片 [${agentName}] 的按钮: ${action}`);
                    // 在这里添加具体的业务逻辑，如跳转、API调用等
                });
            });
            
            // 取消预约函数
            function cancelAppointment(button) {
                const card = button.closest('.appointment-card');
                const agentName = card.querySelector('.agent-name').textContent;
                
                if(confirm(`确定要取消与 ${agentName} 的预约吗？`)) {
                    // 模拟取消成功
                    card.style.transition = 'opacity 0.3s, transform 0.3s';
                    card.style.opacity = '0';
                    card.style.transform = 'scale(0.95)';
                    setTimeout(() => {
                         card.remove();
                         // 重新检查空状态
                         filterAppointments(document.querySelector('.status-tabs .tab.active').getAttribute('data-status')); 
                    }, 300);
                }
            }
        });
    </script>
</body>
</html> 